package Controller;

import Model.Map;
import Model.Pedestrian;
import Model.Player;

import java.util.List;

/**
 * Created by anton.kasiyanenko@stud.fh-luebeck.de on 21.10.2014.
 */
public class MapController {

    private Map map;
    private boolean moving = false;

    public MapController(Map map) {
        this.map = map;
    }

    public void update(float deltaTime, int level) {
        // move player
        if(moving) {

        }

        float targetX;
        int step = 2;

        // move pedastrians
        for (Pedestrian pdstr : map.getPedestrians()) {

            targetX = pdstr.getX() + pdstr.getSpeed() * step * deltaTime * level;

            // bewegt sich der fussgaenger nach rechts und hat die grenze erreicht - an den anfang setzen
            if(pdstr.getSpeed() > 0 && targetX >= 30/*480*/ ) {
                targetX = 0;
            }
            // umgekehrt genauso
            else if(pdstr.getSpeed() < 0 && targetX <= 0) {
                targetX = map.cols;
            }

            pdstr.setX(targetX);
        }
    }
}
